////////////////////////////////////////////////////////////////////////////////
//(c) Intelliquip, Inc. 2001
////////////////////////////////////////////////////////////////////////////////
//$Log:
// 1    Version 10.0 (Current View)1.0         6/1/2011 2:10:38 PM    Scott
//      Frees     
//$
//$NoKeywords$
////////////////////////////////////////////////////////////////////////////////
package com.intelliquip.hydraulicselection.control.web;

import javax.servlet.http.HttpServletRequest;

import com.intelliquip.constants.SelectorMode;
import com.intelliquip.constants.SelectorMode.UnsupportedSelectorModeException;
import com.intelliquip.hydraulicselection.UserPreferences;

public class RedirectAppFactory {

	
	public static RedirectApp buildRedirect(HttpServletRequest request, UserPreferences userPreferences, RedirectParams params) {
		String target = request.getParameter("ConfiguratorTab");
		if ( target.contains("xsheets") ) {
			return new RedirectXSheets(params);
		}
		else {
			RedirectConfig redirectConfig;
			SelectorMode selectorMode = userPreferences.getSelectorMode();
			switch(selectorMode) {
				case Pump:
					redirectConfig = new RedirectConfigForPump(params);
					break;

				case Compressor:
					redirectConfig = new RedirectConfigForCompressor(params);
					break;

				default:
					throw new UnsupportedSelectorModeException(selectorMode);
			}

			return redirectConfig;
		}
	}
}
